﻿<phone:PhoneApplicationPage 
    x:Class="T163.Open.Api.WP7.Sample.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:converter="clr-namespace:T163.Open.Api.WP7.Sample.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:cc="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="False">
    <phone:PhoneApplicationPage.Resources>
        <converter:DateTimeConverter x:Key="dateTimeConverter" />
        <converter:SourceConverter x:Key="sourceConverter" />
        <converter:ReTweetVisibilityConverter x:Key="reTweetVisibilityConverter" />
        <converter:RootStatuesVisibilityConverter x:Key="rootStatuesVisibilityConverter" />
        <DataTemplate x:Key="StatuesTemplate">
            <Border BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="0,0,0,1.5" Margin="12,5,12,5" HorizontalAlignment="Stretch">
                <Grid HorizontalAlignment="Stretch">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Image Source="{Binding Path=User.ProfileImageUrl}" Grid.Column="0" Grid.RowSpan="2" Width="64" Height="64" Stretch="Fill" VerticalAlignment="Top" />

                    <TextBlock Grid.Column="1" Text="{Binding Path=User.Name}" Style="{StaticResource PhoneTextNormalStyle}" HorizontalAlignment="Left" />
                    <TextBlock Grid.Column="2" Text="{Binding Path=CreatedAt, Converter={StaticResource dateTimeConverter}}" Style="{StaticResource PhoneTextNormalStyle}" HorizontalAlignment="Right" />

                    <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Margin="12,5,12,5">
                        <TextBlock Text="{Binding Path=Text}" Margin="0,0,0,5" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" />
                        <Border BorderThickness="1" BorderBrush="#FF151515" Background="#FF151515" CornerRadius="5" Margin="0,5" Visibility="{Binding Path=RootInReplyToStatusText, Converter={StaticResource rootStatuesVisibilityConverter}}" >
                            <TextBlock Text="{Binding Path=RootInReplyToStatusText}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" />
                        </Border>
                    </StackPanel>                    

                    <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding Path=Source, Converter={StaticResource sourceConverter}}" Style="{StaticResource PhoneTextNormalStyle}" />
                    <StackPanel Grid.Column="2" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
                        <StackPanel Orientation="Horizontal" Visibility="{Binding Path=RetweetCount, Converter={StaticResource reTweetVisibilityConverter}}">
                            <Image Source="/Images/appbar.page.arrow.png" Stretch="Fill" Width="32" Height="32" />
                            <TextBlock Text="{Binding Path=RetweetCount}" />
                        </StackPanel>
                        <StackPanel Margin="5,0,0,0" Orientation="Horizontal" Visibility="{Binding Path=CommentsCount, Converter={StaticResource reTweetVisibilityConverter}}">
                            <Image Source="/Images/appbar.reply.people.png" Stretch="Fill" Width="32" Height="32" />
                            <TextBlock Text="{Binding Path=CommentsCount}" />
                        </StackPanel>
                    </StackPanel>
                </Grid>
            </Border>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <TextBox x:Name="txtStatues" Grid.Column="0" Grid.Row="0" TextWrapping="Wrap" HorizontalAlignment="Stretch" Margin="12,12,0,12" />

        <StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="0" Margin="0,12,12,12">
            <Button x:Name="btnStatues" Height="64" Width="64" BorderThickness="0" Padding="0" Click="btnStatues_Click">
                <Image Source="/Images/appbar.arrow.right.png" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Center" />
            </Button>
            <Button x:Name="btnCamera" Height="64" Width="64" BorderThickness="0" Padding="0" Click="btnCamera_Click">
                <Image Source="/Images/appbar.camera.png" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Center" />
            </Button>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Grid.ColumnSpan="2" Margin="0">            
            <ListBox x:Name="lbStatues" ItemsSource="{Binding}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" ItemTemplate="{StaticResource StatuesTemplate}">
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>
        </Grid>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->

</phone:PhoneApplicationPage>